2000W / 48V LLC Battery-Charger  V1.00
xmc_i2s.h
Go to the documentation of this file.
1 
64 #ifndef XMC_I2S_H_
65 #define XMC_I2S_H_
66 
67 /**********************************************************************************************************************
68  * HEADER FILES
69  *********************************************************************************************************************/
70 #include "xmc_usic.h"
71 
85 /*******************************************************************************
86  * MACROS
87  *******************************************************************************/
88 
89 #if defined(USIC0)
90 #define XMC_I2S0_CH0 XMC_USIC0_CH0
91 #define XMC_I2S0_CH1 XMC_USIC0_CH1
92 #endif
93 
94 #if defined(USIC1)
95 #define XMC_I2S1_CH0 XMC_USIC1_CH0
96 #define XMC_I2S1_CH1 XMC_USIC1_CH1
97 #endif
98 
99 #if defined(USIC2)
100 #define XMC_I2S2_CH0 XMC_USIC2_CH0
101 #define XMC_I2S2_CH1 XMC_USIC2_CH1
102 #endif
103 /*******************************************************************************
104  * ENUMS
105  *******************************************************************************/
106 
110 typedef enum XMC_I2S_CH_STATUS
111 {
116 
121 {
138 
143 {
147 
152 {
159 
163 typedef enum XMC_I2S_CH_EVENT
164 {
178 
183 {
189 
193 typedef enum XMC_I2S_CH_CHANNEL
194 {
198 
202 typedef enum XMC_I2S_CH_INPUT
203 {
207 #if UC_FAMILY == XMC1
208  XMC_I2S_CH_INPUT_DIN1 = 3UL,
209  XMC_I2S_CH_INPUT_DIN2 = 4UL,
210  XMC_I2S_CH_INPUT_DIN3 = 5UL
211 #endif
213 
218 {
222 
223 /*******************************************************************************
224  * DATA STRUCTURES
225  *******************************************************************************/
229 typedef struct XMC_I2S_CH_CONFIG
230 {
231  uint32_t baudrate;
232  uint8_t data_bits;
235  uint8_t frame_length;
242 
243 /*******************************************************************************
244  * API PROTOTYPES
245  *******************************************************************************/
246 
247 #ifdef __cplusplus
248 extern "C" {
249 #endif
250 
273 void XMC_I2S_CH_Init(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_CONFIG_t *const config);
274 
289 {
290  /* USIC channel in I2S mode */
292 }
293 
310 
325 XMC_I2S_CH_STATUS_t XMC_I2S_CH_SetBaudrate(XMC_USIC_CH_t *const channel, const uint32_t rate);
326 
338 void XMC_I2S_CH_SetSystemWordLength(XMC_USIC_CH_t *const channel,uint32_t sclk_cycles_system_word_length);
339 
357 void XMC_I2S_CH_Transmit(XMC_USIC_CH_t *const channel, const uint16_t data, const XMC_I2S_CH_CHANNEL_t channel_number);
358 
374 __STATIC_INLINE void XMC_I2S_CH_Receive(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_CHANNEL_t channel_number)
375 {
376  /* Transmit dummy data */
377  XMC_I2S_CH_Transmit(channel, (uint16_t)0xffffU , channel_number);
378 }
379 
393 uint16_t XMC_I2S_CH_GetReceivedData(XMC_USIC_CH_t *const channel);
394 
409 {
410  channel->SCTR &= (uint32_t)~USIC_CH_SCTR_SDIR_Msk;
411 }
412 
427 {
428  channel->SCTR |= (uint32_t)USIC_CH_SCTR_SDIR_Msk;
429 }
430 
447 void XMC_I2S_CH_EnableEvent(XMC_USIC_CH_t *const channel, const uint32_t event);
448 
464 void XMC_I2S_CH_DisableEvent(XMC_USIC_CH_t *const channel, const uint32_t event);
465 
479 {
480  return channel->PSR_IISMode;
481 }
482 
499 __STATIC_INLINE void XMC_I2S_CH_ClearStatusFlag(XMC_USIC_CH_t *const channel, const uint32_t flag)
500 {
501  channel->PSCR |= flag;
502 }
503 
519 {
520  channel->PCR_IISMode |= (uint32_t)USIC_CH_PCR_IISMode_MCLK_Msk;
521 }
522 
536 {
537  channel->PCR_IISMode &= (uint32_t)~USIC_CH_PCR_IISMode_MCLK_Msk;
538 }
539 
554  const XMC_I2S_CH_BRG_SHIFT_CLOCK_OUTPUT_t clock_output)
555 {
558 }
559 
574 __STATIC_INLINE void XMC_I2S_CH_SetWordLength(XMC_USIC_CH_t *const channel, const uint8_t word_length)
575 {
576  XMC_USIC_CH_SetWordLength(channel, word_length);
577 }
578 
594 __STATIC_INLINE void XMC_I2S_CH_SetFrameLength(XMC_USIC_CH_t *const channel, const uint8_t frame_length)
595 {
596  XMC_USIC_CH_SetFrameLength(channel, frame_length);
597 }
598 
615  const XMC_I2S_CH_INPUT_t input,
616  const uint8_t source)
617 {
618  channel->DXCR[input] = (uint32_t)(channel->DXCR[input] & (~USIC_CH_DX0CR_DSEN_Msk)) | USIC_CH_DX0CR_INSW_Msk;
619  XMC_USIC_CH_SetInputSource(channel, (XMC_USIC_CH_INPUT_t)input, source);
620 }
621 
636  const XMC_I2S_CH_WA_POLARITY_t wa_inversion)
637 {
638  /* Configuration of Protocol Control Register */
639  channel->PCR_IISMode = (uint32_t)((channel->PCR_IISMode & (~USIC_CH_PCR_IISMode_SELINV_Msk)) | (uint32_t)wa_inversion);
640 }
641 
658  const XMC_I2S_CH_INPUT_t input)
659 {
661 }
662 
678  const XMC_I2S_CH_INPUT_t input)
679 {
681 }
682 
703  const uint8_t service_request)
704 {
706 }
707 
708 
729  const XMC_I2S_CH_INTERRUPT_NODE_POINTER_t interrupt_node,
730  const uint32_t service_request)
731 {
733  (uint32_t)service_request);
734 }
735 
751 __STATIC_INLINE void XMC_I2S_CH_TriggerServiceRequest(XMC_USIC_CH_t *const channel, const uint32_t service_request_line)
752 {
753  XMC_USIC_CH_TriggerServiceRequest(channel, (uint32_t)service_request_line);
754 }
755 
769 {
771 }
772 
785 {
787 }
788 
804 {
806 }
807 
822 {
824 }
825 
826 #ifdef __cplusplus
827 }
828 #endif
829 
837 #endif /* XMC_I2S_H_ */
__STATIC_INLINE void XMC_I2S_CH_DisableDataTransmission(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:821
__STATIC_INLINE void XMC_I2S_CH_SetFrameLength(XMC_USIC_CH_t *const channel, const uint8_t frame_length)
Definition: xmc_i2s.h:594
void XMC_I2S_CH_SetSystemWordLength(XMC_USIC_CH_t *const channel, uint32_t sclk_cycles_system_word_length)
Definition: xmc_i2s.c:157
enum XMC_USIC_CH_INPUT XMC_USIC_CH_INPUT_t
enum XMC_I2S_CH_BUS_MODE XMC_I2S_CH_BUS_MODE_t
Defines the I2S bus mode.
#define USIC_CH_PSR_IISMode_TSIF_Msk
Definition: XMC1400.h:3360
uint32_t baudrate
Definition: xmc_i2s.h:231
__STATIC_INLINE void XMC_I2S_CH_SelectInterruptNodePointer(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_INTERRUPT_NODE_POINTER_t interrupt_node, const uint32_t service_request)
Definition: xmc_i2s.h:728
#define USIC_CH_PSR_IISMode_WAFE_Msk
Definition: XMC1400.h:3350
#define USIC_CH_PSR_IISMode_DX2S_Msk
Definition: XMC1400.h:3346
__STATIC_INLINE void XMC_USIC_CH_SetFrameLength(XMC_USIC_CH_t *const channel, const uint8_t frame_length)
Definition: xmc_usic.h:1094
__STATIC_INLINE void XMC_I2S_CH_Receive(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_CHANNEL_t channel_number)
Definition: xmc_i2s.h:374
__IO uint32_t PCR_IISMode
Definition: xmc_usic.h:499
#define USIC_CH_PCR_IISMode_DX2TIEN_Msk
Definition: XMC1400.h:3176
void XMC_USIC_CH_SetInterruptNodePointer(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INTERRUPT_NODE_POINTER_t interrupt_node, const uint32_t service_request)
Definition: xmc_usic.c:272
__STATIC_INLINE void XMC_USIC_CH_SetMode(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_OPERATING_MODE_t mode)
Definition: xmc_usic.h:2076
#define USIC_CH_PCR_IISMode_WAFEIEN_Msk
Definition: XMC1400.h:3170
#define USIC_CH_PSR_IISMode_TBIF_Msk
Definition: XMC1400.h:3362
__STATIC_INLINE void XMC_USIC_CH_ConfigureShiftClockOutput(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_BRG_SHIFT_CLOCK_PASSIVE_LEVEL_t passive_level, const XMC_USIC_CH_BRG_SHIFT_CLOCK_OUTPUT_t clock_output)
Definition: xmc_usic.h:2049
enum XMC_I2S_CH_INPUT XMC_I2S_CH_INPUT_t
I2S input stage selection.
__STATIC_INLINE void XMC_USIC_CH_SetStartTransmisionMode(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_START_TRANSMISION_MODE_t start_transmision_mode)
Definition: xmc_usic.h:1229
__STATIC_INLINE void XMC_I2S_CH_SetInterruptNodePointer(XMC_USIC_CH_t *const channel, const uint8_t service_request)
Definition: xmc_i2s.h:702
__STATIC_INLINE void XMC_I2S_CH_ConfigureShiftClockOutput(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_BRG_SHIFT_CLOCK_OUTPUT_t clock_output)
Definition: xmc_i2s.h:553
__STATIC_INLINE void XMC_I2S_CH_EnableDataTransmission(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:803
#define USIC_CH_PCR_IISMode_SELINV_Pos
Definition: XMC1400.h:3167
I2S_CH configuration structure.
Definition: xmc_i2s.h:229
XMC_I2S_CH_BRG_SHIFT_CLOCK_OUTPUT
I2S Baudrate Generator shift clock output.
Definition: xmc_i2s.h:142
enum XMC_I2S_CH_BRG_SHIFT_CLOCK_OUTPUT XMC_I2S_CH_BRG_SHIFT_CLOCK_OUTPUT_t
I2S Baudrate Generator shift clock output.
uint8_t frame_length
Definition: xmc_i2s.h:235
__STATIC_INLINE void XMC_I2S_CH_TriggerServiceRequest(XMC_USIC_CH_t *const channel, const uint32_t service_request_line)
Definition: xmc_i2s.h:751
XMC_I2S_CH_BUS_MODE_t bus_mode
Definition: xmc_i2s.h:240
__STATIC_INLINE void XMC_I2S_CH_SetInputSource(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_INPUT_t input, const uint8_t source)
Definition: xmc_i2s.h:614
#define USIC_CH_PSR_IISMode_WARE_Msk
Definition: XMC1400.h:3352
#define USIC_CH_PCR_IISMode_ENDIEN_Msk
Definition: XMC1400.h:3174
XMC_I2S_CH_BUS_MODE
Defines the I2S bus mode.
Definition: xmc_i2s.h:217
__STATIC_INLINE void XMC_USIC_CH_EnableInputInversion(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input)
Definition: xmc_usic.h:768
__STATIC_INLINE void XMC_I2S_CH_DisableDelayCompensation(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:784
__STATIC_INLINE void XMC_USIC_CH_SetWordLength(XMC_USIC_CH_t *const channel, const uint8_t word_length)
Definition: xmc_usic.h:1017
uint16_t XMC_I2S_CH_GetReceivedData(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.c:224
enum XMC_I2S_CH_EVENT XMC_I2S_CH_EVENT_t
I2S events.
#define USIC_CH_CCR_BRGIEN_Msk
Definition: XMC1400.h:3202
__STATIC_INLINE void XMC_USIC_CH_TriggerServiceRequest(XMC_USIC_CH_t *const channel, const uint32_t service_request_line)
Definition: xmc_usic.h:1348
__STATIC_INLINE void XMC_I2S_CH_Start(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:288
XMC_I2S_CH_STATUS
I2S Status.
Definition: xmc_i2s.h:110
enum XMC_USIC_CH_INTERRUPT_NODE_POINTER XMC_USIC_CH_INTERRUPT_NODE_POINTER_t
enum XMC_I2S_CH_WA_POLARITY XMC_I2S_CH_WA_POLARITY_t
Defines the Polarity of the WA in the SELO output lines in relation to the internal WA signal...
__STATIC_INLINE void XMC_I2S_CH_DisableMasterClock(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:535
__STATIC_INLINE void XMC_USIC_CH_EnableDelayCompensation(XMC_USIC_CH_t *const channel)
Definition: xmc_usic.h:804
#define USIC_CH_PSR_IISMode_DX2TEV_Msk
Definition: XMC1400.h:3348
uint8_t data_bits
Definition: xmc_i2s.h:232
void XMC_I2S_CH_DisableEvent(XMC_USIC_CH_t *const channel, const uint32_t event)
Definition: xmc_i2s.c:264
#define USIC_CH_DX0CR_DSEN_Msk
Definition: XMC1400.h:2854
#define USIC_CH_CCR_DLIEN_Msk
Definition: XMC1400.h:3192
#define USIC_CH_PSR_IISMode_BRGIF_Msk
Definition: XMC1400.h:3368
#define USIC_CH_PSR_IISMode_RIF_Msk
Definition: XMC1400.h:3364
#define USIC_CH_PSR_IISMode_AIF_Msk
Definition: XMC1400.h:3366
#define USIC_CH_CCR_TSIEN_Msk
Definition: XMC1400.h:3194
XMC_I2S_CH_STATUS_FLAG
I2S status flag.
Definition: xmc_i2s.h:120
enum XMC_I2S_CH_STATUS XMC_I2S_CH_STATUS_t
I2S Status.
void XMC_I2S_CH_Transmit(XMC_USIC_CH_t *const channel, const uint16_t data, const XMC_I2S_CH_CHANNEL_t channel_number)
Definition: xmc_i2s.c:204
#define USIC_CH_CCR_RSIEN_Msk
Definition: XMC1400.h:3190
enum XMC_USIC_CH_BRG_SHIFT_CLOCK_PASSIVE_LEVEL XMC_USIC_CH_BRG_SHIFT_CLOCK_PASSIVE_LEVEL_t
__STATIC_INLINE void XMC_I2S_CH_EnableDelayCompensation(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:768
__STATIC_INLINE void XMC_I2S_CH_EnableMasterClock(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:518
#define USIC_CH_CCR_AIEN_Msk
Definition: XMC1400.h:3200
XMC_I2S_CH_STATUS_t XMC_I2S_CH_Stop(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.c:241
#define USIC_CH_DX0CR_INSW_Msk
Definition: XMC1400.h:2850
XMC_I2S_CH_WA_POLARITY
Defines the Polarity of the WA in the SELO output lines in relation to the internal WA signal...
Definition: xmc_i2s.h:182
#define USIC_CH_PCR_IISMode_WAREIEN_Msk
Definition: XMC1400.h:3172
__STATIC_INLINE void XMC_USIC_CH_DisableInputInversion(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input)
Definition: xmc_usic.h:787
#define USIC_CH_CCR_TBIEN_Msk
Definition: XMC1400.h:3196
__STATIC_INLINE void XMC_I2S_CH_ClearStatusFlag(XMC_USIC_CH_t *const channel, const uint32_t flag)
Definition: xmc_i2s.h:499
__STATIC_INLINE uint32_t XMC_I2S_CH_GetStatusFlag(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:478
enum XMC_I2S_CH_STATUS_FLAG XMC_I2S_CH_STATUS_FLAG_t
I2S status flag.
__IO uint32_t SCTR
Definition: xmc_usic.h:494
#define USIC_CH_PCR_IISMode_MCLK_Msk
Definition: XMC1400.h:3180
struct XMC_I2S_CH_CONFIG XMC_I2S_CH_CONFIG_t
I2S_CH configuration structure.
#define USIC_CH_PSR_IISMode_WA_Msk
Definition: XMC1400.h:3344
XMC_I2S_CH_INPUT
I2S input stage selection.
Definition: xmc_i2s.h:202
__IO uint32_t DXCR[6]
Definition: xmc_usic.h:493
__IO uint32_t PSR_IISMode
Definition: xmc_usic.h:509
enum XMC_I2S_CH_INTERRUPT_NODE_POINTER XMC_I2S_CH_INTERRUPT_NODE_POINTER_t
I2S channel interrupt node pointers.
XMC_I2S_CH_EVENT
I2S events.
Definition: xmc_i2s.h:163
enum XMC_USIC_CH_BRG_SHIFT_CLOCK_OUTPUT XMC_USIC_CH_BRG_SHIFT_CLOCK_OUTPUT_t
XMC_I2S_CH_STATUS_t XMC_I2S_CH_SetBaudrate(XMC_USIC_CH_t *const channel, const uint32_t rate)
Definition: xmc_i2s.c:136
#define USIC_CH_PSR_IISMode_DLIF_Msk
Definition: XMC1400.h:3358
XMC_I2S_CH_INTERRUPT_NODE_POINTER
I2S channel interrupt node pointers.
Definition: xmc_i2s.h:151
#define USIC_CH_SCTR_SDIR_Msk
Definition: XMC1400.h:2958
__STATIC_INLINE void XMC_USIC_CH_SetInputSource(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_INPUT_t input, const uint8_t source)
Definition: xmc_usic.h:708
__STATIC_INLINE void XMC_I2S_CH_EnableInputInversion(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_INPUT_t input)
Definition: xmc_i2s.h:657
__O uint32_t PSCR
Definition: xmc_usic.h:514
#define __STATIC_INLINE
Definition: cmsis_gcc.h:47
#define USIC_CH_CCR_RIEN_Msk
Definition: XMC1400.h:3198
__STATIC_INLINE void XMC_I2S_CH_SetBitOrderMsbFirst(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:426
XMC_I2S_CH_CHANNEL
Defines the Polarity of the WA in the SELO output lines in relation to the internal WA signal...
Definition: xmc_i2s.h:193
uint8_t data_delayed_sclk_periods
Definition: xmc_i2s.h:238
void XMC_I2S_CH_EnableEvent(XMC_USIC_CH_t *const channel, const uint32_t event)
Definition: xmc_i2s.c:258
__STATIC_INLINE void XMC_I2S_CH_WordAddressSignalPolarity(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_WA_POLARITY_t wa_inversion)
Definition: xmc_i2s.h:635
enum XMC_I2S_CH_CHANNEL XMC_I2S_CH_CHANNEL_t
Defines the Polarity of the WA in the SELO output lines in relation to the internal WA signal...
void XMC_I2S_CH_Init(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_CONFIG_t *const config)
Definition: xmc_i2s.c:88
__STATIC_INLINE void XMC_USIC_CH_DisableDelayCompensation(XMC_USIC_CH_t *const channel)
Definition: xmc_usic.h:820
#define USIC_CH_PCR_IISMode_SELINV_Msk
Definition: XMC1400.h:3168
__STATIC_INLINE void XMC_I2S_CH_SetBitOrderLsbFirst(XMC_USIC_CH_t *const channel)
Definition: xmc_i2s.h:408
__STATIC_INLINE void XMC_I2S_CH_DisableInputInversion(XMC_USIC_CH_t *const channel, const XMC_I2S_CH_INPUT_t input)
Definition: xmc_i2s.h:677
#define USIC_CH_PSR_IISMode_END_Msk
Definition: XMC1400.h:3354
#define USIC_CH_PSR_IISMode_RSIF_Msk
Definition: XMC1400.h:3356
__STATIC_INLINE void XMC_I2S_CH_SetWordLength(XMC_USIC_CH_t *const channel, const uint8_t word_length)
Definition: xmc_i2s.h:574
XMC_I2S_CH_WA_POLARITY_t wa_inversion
Definition: xmc_i2s.h:239